package de.reminder.client.section;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.user.client.ui.*;

import de.reminder.client.widgets.ReminderStack;

public class AllReminderSection extends Composite {
	private static final int opened = 1;
	private static final int closed = 2;
	
	private AbsolutePanel main;
	private Image folder;
	private TextBox filterReminder;
	private Label title;
	
	private int status;
	
	public AllReminderSection(){
		status = closed;
		main = new AbsolutePanel();
		filterReminder = new TextBox();
		main.add(filterReminder,500,100);
		filterReminder.setVisible(false);
		folder = new Image("images/folder/folderClosed.png");
		folder.addMouseOverHandler(new MouseOverHandler() {
			@Override
			public void onMouseOver(MouseOverEvent event) {
				if(status == closed){
					folder.setUrl("images/folder/folderHalfOpen.png");
				}
			}
		});
		folder.addMouseOutHandler(new MouseOutHandler() {
			@Override
			public void onMouseOut(MouseOutEvent event) {
				if(status == closed){
					filterReminder.setVisible(false);
					folder.setUrl("images/folder/folderClosed.png");
				}
			}
		});
		folder.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				if(status == closed){
					folder.setUrl("images/folder/folderOpened.png");
					filterReminder.setVisible(true);
					main.add(new ReminderStack(),30,135);
					status = opened;
				}
			}
		});
		main.add(folder);
		
		title = new Label("all reminders");
		title.getElement().getStyle().setFontSize(26, Unit.PX);
		main.add(title,90,60);
		title.getElement().setClassName("Handwritten");
		
		initWidget(main);
	}
}
